package com.xinqi.modules.prepare.common.controller.web;

import com.xinqi.common.base.response.R;
import com.xinqi.modules.prepare.common.dto.input.PrepareImportCreateDTO;
import com.xinqi.modules.prepare.common.service.PrepareImportService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 备课区导入服务，课程 -> 备课区
 *
 * @author: system
 * @date: 2023/03/19
 */
@Tag(name = "Web-备课区-导入", description = "备课区-导入Web接口")
@RestController
@RequestMapping("/web/prepare")
@RequiredArgsConstructor
public class PrepareImportWebController {
    private final PrepareImportService prepareImportService;

    /**
     * 将互动课件导入备课区
     */
    @Operation(summary = "将互动课件导入备课区")
    @PostMapping("/{prepare-id}/courseware/import")
    public R<Long> importCourseware(@Parameter(description = "目标备课区Id", example = "100001") @PathVariable("prepare-id") Long prepareId,
                                    @RequestBody PrepareImportCreateDTO dto) {
        dto.setTargetPrepareId(prepareId);
        return R.data(prepareImportService.cascadeImportCourseware(dto));
    }

    /**
     * 将互动视频导入备课区
     */
    @Operation(summary = "将互动视频导入备课区")
    @PostMapping("/{prepare-id}/video/import")
    public R<Long> importVideo(@Parameter(description = "目标备课区Id", example = "100001") @PathVariable("prepare-id") Long prepareId,
                               @RequestBody PrepareImportCreateDTO dto) {
        dto.setTargetPrepareId(prepareId);
        return R.data(prepareImportService.cascadeImportVideo(dto));
    }

    /**
     * 将测评导入备课区
     */
    @Operation(summary = "将测评导入备课区")
    @PostMapping("/{prepare-id}/exam-paper/import")
    public R<Long> importExamPaper(@Parameter(description = "目标备课区Id", example = "100001") @PathVariable("prepare-id") Long prepareId,
                                   @RequestBody PrepareImportCreateDTO dto) {
        dto.setTargetPrepareId(prepareId);
        return R.data(prepareImportService.cascadeImportExamPaper(dto));
    }

}
